package com.xtourms.client.rm.product;

import com.google.gwt.core.client.GWT;
import com.google.gwt.json.client.JSONNumber;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.xtourms.client.ui.util.MoneyLabel;
import com.xtourms.shared.field.ProductField;

public class ProductDetail extends DialogBox {

	private static ProductDetailUiBinder uiBinder = GWT
			.create(ProductDetailUiBinder.class);

	interface ProductDetailUiBinder extends UiBinder<Widget, ProductDetail> {
	}
	
	public ProductDetail(JSONObject productObj) {
		setWidget(uiBinder.createAndBindUi(this));
		setAnimationEnabled(true);
		setAutoHideEnabled(true);
		init(productObj);
	}

	@UiField Label province;
	@UiField Label city;
	@UiField Label pdt_des;
	@UiField MoneyLabel pdt_bp;
	@UiField MoneyLabel pdt_sp;
	@UiField Label start_date;
	@UiField Label end_date;
	
	@UiField Label manager_name;
	@UiField Label manager_mobile;
	@UiField Label linkman_name;
	@UiField Label linkman_mobile;
	@UiField Label linkman_qq;
	
	private void init(JSONObject hotel){
		setText(((JSONString)hotel.get(ProductField.PDT_NAME)).stringValue());
		province.setText(((JSONString)hotel.get(ProductField.PDT_PROVINCE_NAME)).stringValue());
		city.setText(((JSONString)hotel.get(ProductField.PDT_CITY_NAME)).stringValue());
		pdt_des.setText(((JSONString)hotel.get(ProductField.PDT_DES)).stringValue());
		pdt_bp.setText(((JSONNumber)hotel.get(ProductField.PDT_BP)).toString());
		pdt_sp.setText(((JSONNumber)hotel.get(ProductField.PDT_SP)).toString());
		start_date.setText(((JSONString)hotel.get(ProductField.PDT_SD)).stringValue());
		end_date.setText(((JSONString)hotel.get(ProductField.PDT_ED)).stringValue());		
		
		manager_name.setText(((JSONString)hotel.get(ProductField.PDT_MANAGER_NAME)).stringValue());
		manager_mobile.setText(((JSONString)hotel.get(ProductField.PDT_MANAGER_PHONE)).stringValue());
		linkman_name.setText(((JSONString)hotel.get(ProductField.PDT_LINKMAN_NAME)).stringValue());
		linkman_mobile.setText(((JSONString)hotel.get(ProductField.PDT_LINKMAN_PHONE)).stringValue());
		linkman_qq.setText(((JSONString)hotel.get(ProductField.PDT_LINKMAN_QQ)).stringValue());
	}

}
